/**
 *====================================================
* 文件名称: QuarterSettlementServiceImpl.java
 * 修订记录：
  * No    日期				作者(操作:具体内容)
  * 1.    2016年03月21日	chenxy(创建:创建文件)
  *====================================================
  * 类描述：(说明未实现或其它不应生成javadoc的内容)
  */
package com.yuexunit.finance.project.service;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.common.util.RandomUtil;
import com.yuexunit.finance.project.SettingConstants;
import com.yuexunit.finance.project.entity.QuarterSettlementEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.page.PageCriteria;
import com.yuexunit.page.PageList;
import com.yuexunit.persist.PersistUtil;
import com.yuexunit.util.DateUtil;

/**
 * @ClassName: QuarterSettlementServiceImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author chenxy
 * @date 2016年03月21日 09:47:55
 */
@Implements(QuarterSettlementService.class)
public class QuarterSettlementServiceImpl implements QuarterSettlementService {

	@Override
	public Long createQuarterSettlement(QuarterSettlementEntity entity) {
		entity.setSettlementNumber(SettingConstants.PRE_NUMBER_QUARTER_SETTLEMENT + RandomUtil.generateTimeNumber());
		entity.setCreateDateTime(DateUtil.now());
		PersistUtil.insert(entity);
		return entity.getQuarterSettlementId();
	}

	@Override
	public PageList<QuarterSettlementEntity> inquiryInterestSettlement(Long financeId, PageCriteria page) {
		DetachedCriteria criteria = DetachedCriteria.forClass(QuarterSettlementEntity.class);
		if (financeId != null) {
			criteria.add(Restrictions.eq("financeId", financeId));
		}
		return PersistUtil.get(criteria, page);
	}

	@Override
	public QuarterSettlementEntity inquiryInterestSettlementDetail(Long quarterSettlementId) {
		return PersistUtil.get(QuarterSettlementEntity.class, quarterSettlementId);
	}

}
